﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace TestMyAss
{
    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            foreach (String file in System.IO.Directory.GetFiles(@"S:\JAS10613\Tests\Data"))
            {
                comboBox1.Items.Add(new System.IO.FileInfo(file).Name);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string herp;
            TextReader get = new StreamReader(@"S:\JAS10613\Tests\Data\" + comboBox1.Text);
            herp = get.ReadToEnd();
            textBox1.Text = decrypt(herp);
        }
        public string decrypt(string x)
        {
            Encoding ascii = Encoding.ASCII;
            Encoding unicode = Encoding.Unicode;
            byte[] unicodeBytes = unicode.GetBytes(x);
            byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
            char[] asciiChars = new char[ascii.GetCharCount(asciiBytes, 0, asciiBytes.Length)];
            ascii.GetChars(asciiBytes, 0, asciiBytes.Length, asciiChars, 0);
            string ret = new string(asciiChars);
            int num = x.Length - 1;
            for (int i = 0; i <= num; i++)
            {
                if ((x[i] > '\x0002') && (x[i] < '\a'))
                {
                    ret = ret + " ";
                }
                else
                {
                    ret = ret + (char) (x[i] + 128);
                }
            }
            return ret;
        }
    }
}
